package cn.kduck.webapp.security;

import cn.kduck.assembler.security.authentication.AuthenticationType;
import cn.kduck.assembler.security.authentication.LoginCaptchaSender;
import cn.kduck.module.message.service.SmsMessageSender;
import cn.kduck.module.message.service.sender.SenderParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

@Component
public class MyLoginCaptchaSender implements LoginCaptchaSender {

    @Autowired
    private SmsMessageSender messageSender;

    @Override
    public void sendCaptcha(AuthenticationType type, String captcha, String target) {
        SenderParam param = new SenderParam();
        param.setParams(new String[]{"code:"+captcha,"mins:5"});
        param.setPhoneNum(target);
//        param.setTemplateCode("1435344");//腾讯
        param.setTemplateCode("SMS_243425319");//阿里云
        messageSender.sendMessage(param);
    }
}
